package com.yonglian.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yonglian.common.annotation.Log;
import com.yonglian.common.enums.BusinessType;
import com.yonglian.system.domain.CmsActivityStandard;
import com.yonglian.system.service.ICmsActivityStandardService;
import com.yonglian.common.core.controller.BaseController;
import com.yonglian.common.core.domain.AjaxResult;
import com.yonglian.common.utils.poi.ExcelUtil;
import com.yonglian.common.core.page.TableDataInfo;

/**
 * 活动标准Controller
 * 
 * @author gyok
 * @date 2024-05-28
 */
@Controller
@RequestMapping("/system/activityStandard")
public class CmsActivityStandardController extends BaseController
{
    private String prefix = "system/activityStandard";

    @Autowired
    private ICmsActivityStandardService cmsActivityStandardService;

    @RequiresPermissions("system:activityStandard:view")
    @GetMapping()
    public String activityStandard()
    {
        return prefix + "/activityStandard";
    }

    /**
     * 查询活动标准列表
     */
    @RequiresPermissions("system:activityStandard:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(CmsActivityStandard cmsActivityStandard)
    {
        startPage();
        List<CmsActivityStandard> list = cmsActivityStandardService.selectCmsActivityStandardList(cmsActivityStandard);
        return getDataTable(list);
    }

    /**
     * 导出活动标准列表
     */
    @RequiresPermissions("system:activityStandard:export")
    @Log(title = "活动标准", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(CmsActivityStandard cmsActivityStandard)
    {
        List<CmsActivityStandard> list = cmsActivityStandardService.selectCmsActivityStandardList(cmsActivityStandard);
        ExcelUtil<CmsActivityStandard> util = new ExcelUtil<CmsActivityStandard>(CmsActivityStandard.class);
        return util.exportExcel(list, "活动标准数据");
    }

    /**
     * 新增活动标准
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存活动标准
     */
    @RequiresPermissions("system:activityStandard:add")
    @Log(title = "活动标准", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(CmsActivityStandard cmsActivityStandard)
    {
        return toAjax(cmsActivityStandardService.insertCmsActivityStandard(cmsActivityStandard));
    }

    /**
     * 修改活动标准
     */
    @RequiresPermissions("system:activityStandard:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        CmsActivityStandard cmsActivityStandard = cmsActivityStandardService.selectCmsActivityStandardById(id);
        mmap.put("cmsActivityStandard", cmsActivityStandard);
        return prefix + "/edit";
    }

    /**
     * 修改保存活动标准
     */
    @RequiresPermissions("system:activityStandard:edit")
    @Log(title = "活动标准", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(CmsActivityStandard cmsActivityStandard)
    {
        return toAjax(cmsActivityStandardService.updateCmsActivityStandard(cmsActivityStandard));
    }

    /**
     * 删除活动标准
     */
    @RequiresPermissions("system:activityStandard:remove")
    @Log(title = "活动标准", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(cmsActivityStandardService.deleteCmsActivityStandardByIds(ids));
    }
}
